package com.tjl.warehouse.model;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author Tang
 */
@Data
@NoArgsConstructor
public class MyPage<T> implements Serializable {

    //将mybatis-plus分页对象转换为自定义对象
    public MyPage(IPage<T> page){
        this.pageNum = page.getPages();
        this.totalNum = page.getTotal();
        this.pageSize = page.getSize();
        this.pageCount = page.getCurrent();
        this.resultList = page.getRecords();
    }
    //将自定义对象转换为mybatis-plus分页对象
    public IPage<T> toPage(){
        return new Page<>(pageNum,pageSize);
    }
    //当前页码
    private Long pageNum;

    private Long totalNum;

    private Long pageSize;

    private Long pageCount;

    private Long limitIndex;

    private List<T> resultList;


}
